#!/bin/sh
#
# chkconfig: - 85 15
# description: Starts and stops the php-fpm \
#	       used to provide php-fpm network services.
#
# pidfile: /home/programme/php-5.4.5/var/run/php-fpm.pid
# config:  /home/programme/php-5.4.5/etc/php-fpm.conf

# Source function library.
if [ -f /etc/init.d/functions ] ; then
	. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
	. /etc/rc.d/init.d/functions
else
	exit 1
fi


# Check that php-fpm.conf exists.
[ -f /home/programme/php-5.4.5/etc/php-fpm.conf ] || exit 6

RETVAL=0

start() {
    KIND="php-fpm"
	echo -n $"Starting $KIND services: "
	#daemon nginx
	/home/programme/php-5.4.5/sbin/php-fpm
	[ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] || RETVAL=1
	return $RETVAL
}	

reload() {
    echo -n $"Reloading php-fpm.conf file: "
	kill -USR2 `cat /home/programme/php-5.4.5/var/run/php-fpm.pid`
	[ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
	RETVAL=$?
	echo
	return $RETVAL
}	

# Check that we can write to it... so non-root users stop here
[ -w /home/programme/php-5.4.5/etc/php-fpm.conf ] || exit 4



case "$1" in
  start)
  	start
	;;
  reload)
  	reload
	;;
  *)
	echo $"Usage: $0 {start|reload}"
	exit 2
esac

exit $?
